/*
 * virtualdevicevariable.cpp
 *
 *  Created on: 06/01/2012
 *      Author: rbender
 */

#include "virtualdevicevariable.h"
#include "virtualdeviceconfig.h"
using namespace xvd;
using namespace xmlpp;

VirtualDeviceVariable::VirtualDeviceVariable(const Node* node)
{
    const Element* element = dynamic_cast<const Element*> (node);
    m_name = element->get_attribute("name")->get_value();
    m_type = element->get_attribute("type")->get_value();

    if(element->has_child_text())
        m_value = element->get_child_text()->get_content();

    VirtualDeviceConfig::GetInstance()->ValidateVariable(this);
}

VirtualDeviceVariable::VirtualDeviceVariable(const std::string& name, const std::string& type) :
        m_name(name),
        m_type(type)
{
    VirtualDeviceConfig::GetInstance()->ValidateVariable(this);
}

std::string VirtualDeviceVariable::toXml() const
{
    return "";
}

bool VirtualDeviceVariable::fromXml(const std::string& data)
{
    return true;
}

std::string& VirtualDeviceVariable::value()
{
    return m_value;
}

const std::string& VirtualDeviceVariable::name() const
{
    return m_name;
}

const std::string& VirtualDeviceVariable::value() const
{
    return m_value;
}

const std::string& VirtualDeviceVariable::type() const
{
    return m_type;
}
